package org.dizem.groupon.service.impl;

import org.dizem.groupon.dao.ItemDAO;
import org.dizem.groupon.dao.OrderFormDAO;
import org.dizem.groupon.dao.UserDAO;
import org.dizem.groupon.model.Stats;
import org.dizem.groupon.service.CommonService;

/**
 * User: dizem@126.com
 * Time: 11-9-1 上午11:59
 */
public class CommonServiceImpl implements CommonService {
	public UserDAO userDAO;
	public ItemDAO itemDAO;
	public OrderFormDAO orderFormDAO;

	public UserDAO getUserDAO() {
		return userDAO;
	}

	public void setUserDAO(UserDAO userDAO) {
		this.userDAO = userDAO;
	}

	public ItemDAO getItemDAO() {
		return itemDAO;
	}

	public void setItemDAO(ItemDAO itemDAO) {
		this.itemDAO = itemDAO;
	}

	public OrderFormDAO getOrderFormDAO() {
		return orderFormDAO;
	}

	public void setOrderFormDAO(OrderFormDAO orderFormDAO) {
		this.orderFormDAO = orderFormDAO;
	}

	public Stats getStats() {
		Stats stats = new Stats();
		stats.setRegisterUsersAll(userDAO.getCount());
		stats.setRegisterUsersToday(userDAO.getUserRegisterToday());
		stats.setItemAll(itemDAO.getCount());
		stats.setItemPast(itemDAO.getPastCount());
		stats.setItemCurrent(itemDAO.getCurrentCount());
		stats.setOrderAll(orderFormDAO.getCount());
		stats.setOrderToday(orderFormDAO.getTodayCount());
		stats.setOrderSuccess(orderFormDAO.getSuccessCount());
		stats.setOrderWaiting(orderFormDAO.getWaitingCount());
		return stats;
	}
}
